clc;
close all;


%% Paper
Vin=[40];

figure;
cc=hsv(length(Vin));
marker={'x-'; 'o-';'^-';'*-'};
for i=1:length(Vin)
    sprintf('./data/SC_efficiency_current_hard_%iV_350k_short.dat',Vin(i))
    M = csvread(sprintf('./data/SC_efficiency_current_hard_%iV_350k_short.dat',Vin(i)),1,0);
    efficiency=M(:,7);
    current=M(:,4);
    plot(current,efficiency,marker{1},'color',cc(i,:),'LineWidth',0.75);
    hold all;
    legendInfo{1} = 'Short';
end
for i=1:length(Vin)
    sprintf('./data/SC_efficiency_current_hard_%iV_350k_long.dat',Vin(i))
    M = csvread(sprintf('./data/SC_efficiency_current_hard_%iV_350k_long.dat',Vin(i)),1,0);
    efficiency=M(:,7);
    current=M(:,4);
    plot(current,efficiency,marker{2},'color',cc(i,:),'LineWidth',0.75);
    hold all;
    legendInfo{2} = 'Long';
end
for i=1:length(Vin)
    sprintf('./data/SC_efficiency_current_hard_%iV_350k_no.dat',Vin(i))
    M = csvread(sprintf('./data/SC_efficiency_current_hard_%iV_350k_no.dat',Vin(i)),1,0);
    efficiency=M(:,7);
    current=M(:,4);
    plot(current,efficiency,marker{3},'color',cc(i,:),'LineWidth',0.75);
    hold all;
    legendInfo{3} = 'No';
end
for i=1:length(Vin)
    sprintf('./data/SC_efficiency_current_hard_%iV_350k_no2.dat',Vin(i))
    M = csvread(sprintf('./data/SC_efficiency_current_hard_%iV_350k_no2.dat',Vin(i)),1,0);
    efficiency=M(:,7);
    current=M(:,4);
    plot(current,efficiency,marker{4},'color',cc(i,:),'LineWidth',0.75);
    hold all;
    legendInfo{4} = 'No2';
end
xlabel('Iout (A)');
ylabel('Efficiency');
legend(legendInfo,'Location','NorthEast');
grid on;
% ylim([65 100]);
% xlim([0 3.1]);

set(gcf, 'Position', [200 200 450 300])
set(gcf,'PaperPositionMode','auto')
% print('-depsc2', '../Paper/images/efficiency_unregulated_exp');
% matlab2tikz( '../Paper/images/efficiency_unregulated_exp.tikz',  'height', '\figureheight', 'width', '\figurewidth','showInfo', false);
%% hard vs soft
% Vin=[55 90]
% 
% figure;
% cc=hsv(length(Vin)+1)
% cc=[cc(1,:);cc(3,:)];
% marker={'o-', 'x-';'o--','x--'};
% for i=1:length(Vin)
%     M = csvread(sprintf('../Measurements/250k/SC_%i.dat',Vin(i)),2,0);
%     plot(M(3:end,4),M(3:end,7)*100,marker{1,i},'color',cc(1,:),'LineWidth',0.75);
%     hold all;
%     legendInfo{i} = sprintf('Soft-charging V_{in}=%i V',Vin(i));
% end
% for i=1:length(Vin)
%     M = csvread(sprintf('../Measurements/250k/SC_hard_%i.dat',Vin(i)),2,0);
%     hold all;
%     plot(M(:,4),M(:,7)*100,marker{2,i},'color',cc(2,:),'LineWidth',0.75);
%     legendInfo{i+2} = sprintf('Hard charging V_{in}=%i V',Vin(i));
% end
% xlabel('I_{out} (A)');
% ylabel('Efficiency (%)');
% legend(legendInfo,'Location','SouthEast');
% grid on;
% ylim([75 100]);
% xlim([0 3.1]);
% 
% set(gcf, 'Position', [200 200 450 300])
% set(gcf,'PaperPositionMode','auto')
% % print('-depsc2', '../Paper/images/efficiency_unregulated_compare_exp');
% % matlab2tikz( '../Paper/images/efficiency_unregulated_compare_exp.tikz',  'height', '\figureheight', 'width', '\figurewidth','showInfo', false);
% 
% 
% %% Power loss compare
% 
% Vin=[55 90]
% 
% figure;
% cc=hsv(length(Vin)+1);
% cc=[cc(1,:);cc(3,:)];
% marker={'o-', 'x-';'o--','x--'};
% for i=1:length(Vin)
%     M = csvread(sprintf('../Measurements/250k/SC_%i.dat',Vin(i)),2,0);
%     hold all;
%     plot(M(3:end,4),M(3:end,5)-M(3:end,6),marker{1,i},'color',cc(1,:),'LineWidth',0.75);
%     legendInfo{i} = sprintf('Soft-charging V_{in}=%i V',Vin(i));
% end
% for i=1:length(Vin)
%     M = csvread(sprintf('../Measurements/250k/SC_hard_%i.dat',Vin(i)),2,0);
%     hold all;
%     plot(M(:,4),M(1:end,5)-M(:,6),marker{2,i},'color',cc(2,:),'LineWidth',0.75);
%     legendInfo{i+2} = sprintf('Hard charging V_{in}=%i V',Vin(i));
% end
% 
% 
% xlabel('Iout (A)');
% ylabel('Power loss (W)');
% legend(legendInfo,'Location','NorthWest');
% grid on;
% ylim([0 4]);
% xlim([0 3.1]);
% 
% set(gcf, 'Position', [200 200 450 300])
% set(gcf,'PaperPositionMode','auto')
% % % print('-depsc2', '../efficiency_unregulated_compare_exp');
% matlab2tikz( '../Paper/images/powerloss_unregulated_compare_exp.tikz',  'height', '\figureheight', 'width', '\figurewidth','showInfo', false);
% end